package com.xiaoshi.utils;


import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
import com.xiaoshi.enums.JsonReturnEnums;
import com.xiaoshi.interfaces.Constants;
import com.xiaoshi.interfaces.MyHttpServiceCode;

public class MapUtils {
    public static Map put(Object obj) {
        HashMap<String, Object> map = Maps.newHashMap();
        map.put(Constants.myConstans.MSG, obj);
        map.put(Constants.myConstans.DATA, null);
        return map;
    }

    public static Map put(String code, String obj) {
        HashMap<String, Object> map = Maps.newHashMap();
        map.put(Constants.myConstans.CODE, code);
        map.put(Constants.myConstans.MSG, obj);
        return map;
    }

    public static Map put(String msg, Object obj) {
        HashMap<String, Object> map = Maps.newHashMap();
        map.put(msg, obj);
        return map;
    }


    /**
     * token 增强器
     * @param obj
     * @return
     */
    public static Map cusTokenput( Object obj) {
        HashMap<String, Object> map = Maps.newHashMap();
        map.put(Constants.myConstans.USERINFO, obj);
        map.put(Constants.myConstans.CODE, MyHttpServiceCode.SC_OK);
        return map;
    }

    /**
     * 404 自定义
     * NOT_FOUND
     */
    public static Map not404Found() {
        HashMap<String, Object> map = Maps.newHashMap();
        map.put(Constants.myConstans.MSG, JsonReturnEnums.RESCOUSE_NO_FIND.getDesc());
        map.put(Constants.myConstans.CODE, JsonReturnEnums.RESCOUSE_NO_FIND.getCode());
        map.put(Constants.myConstans.DATA, null);
        return map;
    }



    public static Map returnEnumsData(JsonReturnEnums jsonReturnEnums) {
        HashMap<String, Object> map = Maps.newHashMap();
        map.put(Constants.myConstans.MSG, jsonReturnEnums.getDesc());
        map.put(Constants.myConstans.CODE, jsonReturnEnums.getCode());
        map.put(Constants.myConstans.DATA, null);
        return map;
    }
}
